let proto = cc.Vec2.prototype;


/**
 * Moves a point current in a straight line towards a target point.
 * 实现unity3d的Vector3.MoveTowards
 * @param current
 * @param target
 * @param maxDistanceDelta
 * @returns {*}
 */
proto.moveTowards = function (current, target, maxDistanceDelta) {
  let vector = target.sub(current);
  let magnitude = vector.mag();
  if (magnitude <= maxDistanceDelta || magnitude === 0) {
    return target;
  }
  return current.addSelf(vector.divSelf(magnitude).mulSelf(maxDistanceDelta));
};
